package com.link.listener;

import com.link.config.SpringContextHolder;
import com.link.service.GitPullService;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName StartupListener
 * @Description TODO
 * @Author linK
 * @Date 2023/12/6 11:26
 * @Version 1.0
 **/
@Component
public class StartupListener implements ApplicationListener<ApplicationStartedEvent> {

    @Override
    public void onApplicationEvent(ApplicationStartedEvent event) {
        // 在Spring应用启动完成后执行的操作
        GitPullService bean = SpringContextHolder.getBean(GitPullService.class);
        System.out.println("启动初始化时执行一次");
        bean.gitPull();
    }
}
